<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        img{
            max-width: 100%;
        }
    </style>
</head>
<body>
<img id="xxx"  src="https://cdn.jsdelivr.net/gh/lihua01/cdn@1.1/images/touxiang.jpg" alt="A photo">
<script>
    xxx.onload = function () {
        console.log("图片加载成功");

    }
    xxx.onerror= function () {
        console.log("图片加载失败");
       // xxx.src='/404.png';

    }
</script>
</body>
</html>